# -*- coding: utf-8 -*-
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.http import JsonResponse
from django.contrib.auth.decorators import login_required

import urllib
from .saltapi import salt

def action(req, action):
    '''
    @match参数格式: 可用通配符, 多个minion id用逗号隔开
    '''
    action = 'list_all' if action == 'query' else action
    params = {
        'client': 'wheel',
        'fun': 'key.' + action,
        'match': req.GET.get('match', '')
    }
    return JsonResponse(salt.postRequest(params))
